import { mtree } from './comlib.js'

const mdata = [
    {
        "name" : "DP",
        "children" : [
            { "name" : "DPI", },
            { "name" : "DPE", },
        ]
    },
    {
        "name" : "CP",
        "children" : [
            { "name" : "MR", },
            { "name" : "ADM", },
        ]
    },
]

// Test0
const res0 = mtree( mdata ).map(
    (n,i,r,s,w) => {return {"name":`${n.name}_${i.length}`, "children":r}}
).node

const res1 = res0[0].name==="DP_0" && 
    res0[0].children[0].name==="DPI_1" &&
    res0[0].children[1].name==="DPE_1" &&
    res0[1].name==="CP_0" &&
    res0[1].children[0].name==="MR_1" &&
    res0[1].children[1].name==="ADM_1"

console.log(res1)